package com.jsb.laundry.service.impl;

import com.jsb.laundry.common.utils.JSBUtil;
import com.jsb.laundry.dao.ServeDao;
import com.jsb.laundry.model.entity.CapitalAccount;
import com.jsb.laundry.model.entity.CapitalAccountUnstLog;
import com.jsb.laundry.model.vo.PayListVo;
import com.jsb.laundry.service.ServeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ServeServiceImpl implements ServeService {

    @Resource
    private ServeDao serveDao;

    /**
     * 查询服务
     *
     * @param id
     * @return
     */
    @Override
    public Map findServiceById(String id) {
        return serveDao.findServiceById(id);
    }

    /**
     * 支付列表
     *
     * @return
     */
    @Override
    public List<PayListVo> payList() {
        return serveDao.payList();
    }

    /**
     * 根据userid查询用户
     *
     * @param userId
     * @return
     */
    @Override
    public String findByOpenId(String userId) {
        if (!JSBUtil.isEmptyString(userId)){
            String byOpenId = serveDao.findByOpenId(userId);
            return byOpenId;
        }
        return null;
    }

    @Override
    public int addCapitalAccountUnstLog(CapitalAccountUnstLog capitalAccountLog) {
        return serveDao.addCapitalAccountUnstLog(capitalAccountLog);
    }

    @Override
    public CapitalAccount capitalAccountInfo(String thirdpartId, String type) {
        return serveDao.capitalAccountInfo(thirdpartId,type);
    }

    @Override
    public CapitalAccount capitalAccountInfoForUpdate(String id) {
        return serveDao.capitalAccountInfoForUpdate(id);
    }

    @Override
    public int findByUserIdOkFlag(String userId) {
        return serveDao.findByUserIdOkFlag(userId);
    }

    /**
     * 查看开通服务
     *
     * @param userId
     * @return
     */
    @Override
    public List<HashMap> findOpenServiceLogByUserId(String userId) {
        return serveDao.findOpenServiceLogByUserId(userId);
    }

    @Override
    public int addOpenServiceLogInfo(String serviceId, String userId, String payId) {
        return serveDao.addOpenServiceLogInfo(serviceId, userId, payId);
    }

    @Override
    public int updateStatus(String payId) {
        return serveDao.updateStatus(payId);
    }

    @Override
    public int findByUserId(String thirdpartId) {
        return serveDao.findByUserId(thirdpartId);
    }

    @Override
    public List<CapitalAccountUnstLog> findByCapitalAccountUnstLogList(String relatedNo) {
        return serveDao.findByCapitalAccountUnstLogList(relatedNo);
    }

    @Override
    public int capitalAccountLogadd(CapitalAccountUnstLog capitalAccount) {
        return serveDao.capitalAccountLogadd(capitalAccount);
    }

    @Override
    public int findByOrderMoney(String orderId) {
        return serveDao.findByOrderMoney(orderId);
    }

    @Override
    public int addUserInfo(String thirdpartId) {
        return serveDao.addUserInfo(thirdpartId);
    }

    @Override
    public int updByUserId(String thirdpartId, int frozenAmount) {
        return serveDao.updByUserId(thirdpartId,frozenAmount);
    }

    @Override
    public CapitalAccount findByCapitalAccount(String userId) {
        return serveDao.findByCapitalAccount(userId);
    }

    @Override
    public String findByUserIdAndPayId(String userId) {
        return serveDao.findByUserIdAndPayId(userId);
    }

    /**
     * 更新待结算
     *
     * @param amount
     * @param id
     * @return
     */
    @Override
    public int updatedepositfreezeadd(int amount, String id) {
        return serveDao.updatedepositfreezeadd(amount,id);
    }

    @Override
    public int updatedepositfreezesub(int amount, String id) {
        return serveDao.updatedepositfreezesub(amount,id);
    }

    @Override
    public int updateDepositAdd(int amount, String id) {
        return serveDao.updateDepositAdd(amount,id);
    }

    @Override
    public int updateDepositSub(int amount, String id) {
        return serveDao.updateDepositSub(amount,id);
    }

    @Override
    public int updateIsSett(String relatedNo,String id) {
        return serveDao.updateIsSett(relatedNo,id);
    }

    /**
     * 累计收入
     *
     * @param userId
     * @return
     */
    @Override
    public String accumulatedIncome(String userId) {
        return serveDao.accumulatedIncome(userId);
    }

    /**
     * 上岗考试分数查询
     *
     * @param userId
     * @return
     */
    @Override
    public int findByUserIdFraction(String userId) {
        return serveDao.findByUserIdFraction(userId);
    }

    /**
     * 查询改用户是否参与答题
     *
     * @param userId
     * @return
     */
    @Override
    public int findByQuestionLog(String userId) {
        return serveDao.findByQuestionLog(userId);
    }

    @Override
    public String payid(String payId) {
        return serveDao.payid(payId);
    }

}
